Shader "Custom/CircleRipple"
{
    Properties
    {
        _Color ("Color", Color) = (1,1,0,1) // 暖黄色
        _Center ("Center", Vector) = (0.5, 0.5, 0, 0) // 光圈中心，用Vector定义，第三和第四个值可以为0
        _Radius ("Radius", Float) = 0.0 // 光圈半径
        _Thickness ("Thickness", Float) = 0.05 // 光圈宽度
    }
    SubShader
    {
        Tags {"Queue"="Overlay" }
        Pass
        {
            ZTest Always
            ZWrite Off
            Cull Off
            Blend SrcAlpha OneMinusSrcAlpha

            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            #include "UnityCG.cginc"

            struct appdata
            {
                float4 vertex : POSITION;
                float2 uv : TEXCOORD0;
            };

            struct v2f
            {
                float2 uv : TEXCOORD0;
                float4 vertex : SV_POSITION;
            };

            float4 _Color;
            float4 _Center; // 现在是 float4 而不是 float2
            float _Radius;
            float _Thickness;

            v2f vert (appdata v)
            {
                v2f o;
                o.vertex = UnityObjectToClipPos(v.vertex);
                o.uv = v.uv;
                return o;
            }

            fixed4 frag (v2f i) : SV_Target
            {
                float2 dist = i.uv - _Center.xy; // 仅使用 _Center 的 xy 部分
                float len = length(dist);

                // 计算光圈透明度
                float alpha = smoothstep(_Radius, _Radius + _Thickness, len) - smoothstep(_Radius + _Thickness, _Radius + _Thickness * 2.0, len);

                return float4(_Color.rgb, _Color.a * alpha);
            }
            ENDCG
        }
    }
}